Class spinitron\dynamicAr\ValueExpression

Inheritancespinitron\dynamicAr\ValueExpression » yii\base\Object
Implementsyii\base\Configurable

A ValueExpression object represents the value of a dynamic attribute that DynamicActiveRecord uses directly (unescaped) in SQL instead of using PDOStatement::bindValue.

Example:

$model->width = new ValueExpression(123.456);

You may optionally give an SQL datatype as second argument of the constructor, for example:

$model->joined = new ValueExpression('"2015-06-01 12:30:00"', 'DATETIME');
$model->price = new ValueExpression(4.99, 'DECIMAL(6,2)');

Note: because values are not escaped or bound using PDO, for string values (including date and time types) you must provide the SQL quotes around the string in the value.

Note: using ValueExpression for the value of a column attribute rather than a dynamic attribute will cause an error.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$type null|string The value's [SQL datatype](https://mariadb. spinitron\dynamicAr\ValueExpression
$value mixed The dynamic attribute value. spinitron\dynamicAr\ValueExpression

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. yii\base\Object
__construct() Constructor. spinitron\dynamicAr\ValueExpression
__get() Returns the value of an object property. yii\base\Object
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Object
__set() Sets value of an object property. yii\base\Object
__toString() To string magic method. spinitron\dynamicAr\ValueExpression
__unset() Sets an object property to null. yii\base\Object
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Object
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Object
className() Returns the fully qualified name of this class. yii\base\Object
hasMethod() Returns a value indicating whether a method is defined. yii\base\Object
hasProperty() Returns a value indicating whether a property is defined. yii\base\Object
init() Initializes the object. yii\base\Object

Property Details

$type public property

The value's SQL datatype (optional)

public null|string $type null
$value public property

The dynamic attribute value.

public mixed $value null

Method Details

__construct() public method

Constructor.

public void __construct ( $value, $type null, $config = [] )
$value mixed

The dynamic attribute value.

$type string

The value's SQL datatype. Omit or set null to not specify a datatype.

$config array

Name-value pairs to initialize object properties.

__toString() public method

To string magic method.

public string __toString ( )
return string

The dynamic value's SQL expression.